﻿#region GNU General Public License
// XEdit2D - XNA 2D Asset Editor
// Copyright (C) 2010  HurlBat Games

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
#endregion

using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace HurlBat.Data2D.Map
{
    /// <summary>
    /// Represents a full set of tiles to be used on a map
    /// </summary>
    public class TileSet
    {
        TileSetType type;
        /// <summary>
        /// The type of the current tile set
        /// </summary>
        public TileSetType Type { get { return type; } set { type = value; } }

        Point tileSize;
        /// <summary>
        /// The size of a tile belonging to this tileset. Normally all tiles should have this size.
        /// </summary>
        public Point TileSize { get { return tileSize; } set { tileSize = value; } }

        List<string> tileTypes;
        /// <summary>
        /// The list of possible types for the tile (ex. grass, stone, sand...)
        /// </summary>
        public List<string> TileTypes { get { return tileTypes; } set { tileTypes = value; } }

        string defaultTile = null;
        /// <summary>
        /// The default tile to be used if nothing is there.
        /// </summary>
        [ContentSerializer(Optional = true)]
        public string DefaultTile { get { return defaultTile; } set { defaultTile = value; } }

        Dictionary<string, Dictionary<string, Graphics.Image>> tiles;
        /// <summary>
        /// The complete list of all possible tiles in the set
        /// </summary>
        public Dictionary<string, Dictionary<string, Graphics.Image>> Tiles { get { return tiles; } set { tiles = value; } }

        /// <summary>
        /// The constructor
        /// </summary>
        public TileSet()
        {
            tiles = new Dictionary<string, Dictionary<string, Graphics.Image>>();
        }

        /// <summary>
        /// Get a tile from the set
        /// </summary>
        /// <param name="_type">The type of the tile</param>
        /// <param name="_direction">The direction of the tile</param>
        /// <returns></returns>
        public Graphics.Image GetTile(string _type, string _direction)
        {
            return tiles[_type][_direction];
        }
    }
}
